/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mbox.model;

/**
 *
 * @author Hallucinogen
 */
public class Pair<A, B> {
    public Pair(A first, B second) {
        First   = first;
        Second  = second;
    }

    @Override
    public int hashCode() {
        int hashFirst = First != null ? First.hashCode() : 0;
        int hashSecond = Second != null ? Second.hashCode() : 0;

        return (hashFirst + hashSecond) * hashSecond + hashFirst;
    }

    @Override
    public boolean equals(Object other) {
        if (other instanceof Pair) {
            Pair otherPair = (Pair) other;
            return ((  this.First == otherPair.First ||
                    ( this.First != null && otherPair.First != null &&
                      this.First.equals(otherPair.First))) &&
                    ( this.Second == otherPair.Second ||
                    ( this.Second != null && otherPair.Second != null &&
                      this.Second.equals(otherPair.Second))) );
        }

        return false;
    }

    @Override
    public String toString()
    {
           return "(" + First + ", " + Second + ")";
    }

    public A First;
    public B Second;
}
